package com.ijunfu.proxy._01_jdk;

import com.ijunfu.proxy._01_jdk.service.IService;
import com.ijunfu.proxy._01_jdk.service.impl.ServiceImpl;

import java.lang.reflect.Proxy;

/**
 *
 * @title  : 
 * @author : ijunfu <ijunfu@163.com>
 * @date   : 2023/10/29 15:27
 * @version: 1.0
 * @motto  : 位来可期 - 世界很大，我想看看
 *
 */
public class JdkProxyMain {

    public static void main(String[] args) {
        // 将生成的代理类保存为class文件
        // JDK 8- 修改代理类生成的目录
//        System.setProperty("sun.misc.ProxyGenerator.saveGeneratedFiles", "true");

        // JDK 8+
        System.setProperty("jdk.proxy.ProxyGenerator.saveGeneratedFiles", "true");

        IService service = (IService) Proxy.newProxyInstance(
                IService.class.getClassLoader(),
                IService.class.getInterfaces(),
                new ServiceProxy(new ServiceImpl())
        );

        service.log();
    }

}
